#include "regx52.h"
#include "STC89C5xRC-rdp.h"
#include "datatype.h"
#include "bit.h"
#include "delay.h"

#include "uart.h"
#include "hc-sr04.h"

#define LEN 12

uint_8 distance_str[LEN];

void setup(void)
{
	/* put your setup code here, to run once: */
	uart_init(BAUD_RATE_9600);
	time0_init();
	delay_10us();
}

void main(void)
{
	setup();

	while(TRUE) {
		/* put your main code here, to run repeatedly: */
		ES = TURN_OFF;
		EA = TURN_OFF;
		//distance_string(distance_str, LEN);
		printf("%.2lfcm\r\n", get_distance());
		delay_1s();
	}
}